package com.linkoog.devtools.code_generator.setting.configurable.ui.variable;

import java.util.ArrayList;
import java.util.List;

/**
 * 用于展示模板可以配置的参数表头
 *
 * @author fox
 */
public enum VariableEnum {
    Name("名称",0),
    ParamName("参数名",1),
    ParamType("参数类型",2),
    ParamDefault("默认值",3),
    ParamExplain("配置示例",4);

    private String name;
    private int index;

    VariableEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static List<String> getSampleList(){
        List<String> list = new ArrayList<String>();
        for(VariableEnum c : VariableEnum.values()){
            list.add(c.getName());
        }
        return list;
    }

    public static String[] getSamples(){
        List<String> list = getSampleList();
        return list.toArray(new String[list.size()]);
    }

    public static VariableEnum get(String name){
        if(name==null){
            return null;
        }
        for(VariableEnum c: VariableEnum.values()){
            if(name.toLowerCase().equals(c.getName().toLowerCase())){
                return c;
            }
        }
        return null;
    }

    public static VariableEnum getByOrder(int order){
        for(VariableEnum c: VariableEnum.values()){
            if(order==c.getIndex()){
                return c;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }
}
